﻿<%@ Page Language="C#" MasterPageFile="~/share/AdminMasterPage.Master"
AutoEventWireup="true" CodeBehind="ManageAdmin.aspx.cs" Inherits="AKMII.DMRA.Web.ManageAdmin" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="LinkContent" runat="server">
    <a id="breadcrumb_home" href="#">Home</a>&nbsp;&gt;&nbsp; <a id="A1" href="javascript:void(0);">
        Admin Home Page</a>&nbsp;&gt;&nbsp; <a id="A2" href="javascript:void(0);">Admin Manage</a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="DetailsContent" runat="server">

    <script type="text/javascript">
        function UserCheck(chbItem) {
            if (!chbItem.checked) {
                if (!confirm("You are about to disable this Administrator. Do you want to continue?")) {
                    chbItem.checked = true;
                }
            }
        }
        
        function CheckSelected()
        {
            var table=document.getElementById("ctl00_DetailsContent_GridView1");
            var sum=0;
            var otherselected=parseInt(document.getElementById("ctl00_DetailsContent_txtSelectedCount").value,10);
            for(var j=1;j<table.rows.length;j++)
            {
                var checkboxs=table.rows[j].cells[0].getElementsByTagName("input"); 
                for(var i=0;i<checkboxs.length;i++)
                {
                    if(checkboxs[i].type=="checkbox")
                    {
                        if(checkboxs[i].checked)
                        {
                            sum++;
                        }
                    }
                }
            }
            if((sum+otherselected)==0)
            {
                alert("You should select one Admin at least before delete!");
                return false;
            }
            else
            {
                if(!confirm("You are about to delete admin. This person will no longer have access to the combined site. Are you sure you want to do this?"))
                {
                    return false;
                }
            }
        }
    </script>

    <div class="addmd">
        <asp:Button ID="btnDelete"  OnClientClick='return CheckSelected();' runat="server" CssClass="loginbuttonBtn" Text="Delete"
            OnClick="btnDelete_Click" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" class="loginbuttonBtn" value="Add" onclick="divmask.style.visibility='visible';divmassage_box.style.visibility='visible'" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnSave" runat="server" CssClass="loginbuttonBtn" Text="Save" OnClick="btnSave_Click" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnCancel" runat="server" CssClass="loginbuttonBtn" Text="Cancel"
            OnClick="btnCancel_Click" /><asp:HiddenField ID="txtSelectedCount" runat="server" />
    </div>
    <br />
    <div id="admincontentContainnerDiv" class="admincontentContainnerDiv">
        <asp:GridView ID="GridView1" AllowPaging="True" Width="98%" CssClass="leadtable"
            runat="server" AutoGenerateColumns="False" BorderWidth="0px" OnPageIndexChanging="GridView1_PageIndexChanging"
            OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit"
            OnRowUpdating="GridView1_RowUpdating" PageSize="100">
            <HeaderStyle CssClass="ItemListHeaderRow" BorderWidth="1px" />
            <Columns>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" Width="20px" />
                    <ItemTemplate>
                        <asp:CheckBox ID="chbItem" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" Width="80px" />
                    <HeaderTemplate>
                        Admin ID
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%# Eval("Id")%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" Width="80px" />
                    <HeaderTemplate>
                        FirstName
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%# Eval("FirstName")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtFirstName" Text='<%# Bind("FirstName") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" Width="80px" />
                    <HeaderTemplate>
                        LastName
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%# Eval("LastName")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtLastName" Text='<%# Bind("LastName") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" />
                    <HeaderTemplate>
                        Email
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%# Eval("Email")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtEmail" Text='<%# Bind("Email") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLeft" Width="60px" />
                    <HeaderTemplate>
                        Status
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbActive" Enabled="false" Text="Active" runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:CheckBox ID="chbActive" Text="Active" runat="server" />
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader"  />
                    <HeaderStyle CssClass="BorderLeft" Width="50px" />
                    <ItemTemplate>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:LinkButton ID="linkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkUpdate" runat="server" CommandName="Update">Update</asp:LinkButton>
                        <asp:LinkButton ID="LinkCancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton>
                    </EditItemTemplate>
                    <ItemStyle Width="20px"/>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <table cellpadding="0" width="100%" cellspacing="0" border="1" id="ItemListContentTable"
                    class="leadtable">
                    <tr class="ItemListHeaderRow">
                        <th class="BorderLeft">
                            <input type="checkbox" disabled="disabled" />
                        </th>
                        <th class="BorderLeft">
                            Admin ID
                        </th>
                        <th class="BorderLeft">
                            FristName
                        </th>
                        <th class="BorderLeft">
                            LastName
                        </th>
                        <th class="BorderLeft">
                            Email
                        </th>
                        <th class="BorderLeft">
                            Status
                        </th>
                    </tr>
                    <tr>
                        <td colspan="25" style="height: 40px;" valign="middle" align="center">
                            There is no record.
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>
        </asp:GridView>
        <div id="divmassage_box" style="width: 350px; height: 400px;">
            <div class="divmassage">
                <div class="divheader">
                    <div style="display: inline; width: 150px; position: absolute">
                        Add Administrator
                    </div>
                    <span onclick="divmassage_box.style.visibility='hidden'; divmask.style.visibility='hidden'"
                        style="float: right; display: inline; cursor: hand"></span></div>
                <table cellpadding="0" width="100%" cellspacing="0" border="1" id="ItemListContentTable"
                    class="leadtable">
                    <tr class="ItemListHeaderRow">
                        <th class="BorderLeft">
                            &nbsp;
                        </th>
                        <th class="BorderLeft">
                            &nbsp;
                        </th>
                    </tr>
                    <tr>
                        <td class="subheader">
                            Admin ID
                        </td>
                        <td class="subheader">
                            <asp:TextBox ID="txtAddMDId" runat="server" BorderWidth="1px" BorderColor="LightSlateGray"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="subheader">
                            FirstName
                        </td>
                        <td class="subheader">
                            <asp:TextBox ID="txtAddFirstName" runat="server" BorderWidth="1px" BorderColor="LightSlateGray"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="subheader">
                            LastName
                        </td>
                        <td class="subheader">
                            <asp:TextBox ID="txtAddLastName" runat="server" BorderWidth="1px" BorderColor="LightSlateGray"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="subheader">
                            Email
                        </td>
                        <td class="subheader">
                            <asp:TextBox ID="txtAddEmail" runat="server" BorderWidth="1px" BorderColor="LightSlateGray"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="height: 40px;" valign="middle" align="center">
                            <asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="loginbuttonBtn" OnClick="btnAdd_Click" />
                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            <input type="reset" class="loginbuttonBtn" value="Close" onclick="divmassage_box.style.visibility='hidden'; divmask.style.visibility='hidden'"" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="divmask">
        </div>
    </div>
</asp:Content>